from datetime import datetime

from django.db import models
from Apps.Profile.models import User
from Apps.Article.models import Article


class UserFav(models.Model):
    """
    用户收藏
    """
    user = models.ForeignKey(User, verbose_name="用户", on_delete=models.DO_NOTHING)
    Article = models.ForeignKey(Article, verbose_name="文章", help_text="文章id", on_delete=models.DO_NOTHING)
    add_time = models.DateTimeField(default=datetime.now, verbose_name=u"添加时间")

    class Meta:
        verbose_name = '用户收藏'
        verbose_name_plural = verbose_name
        unique_together = ("user", "Article")

    def __str__(self):
        return self.user.username
